Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

443
Views
Why is my AWS Congito user able to sign in, but "not authenticated" when using Auth.currentAuthenticatedUser()?

I have manually added an AWS Cognito user to my application's user pool via the AWS management console. The required user pool credentials have been confirmed for this user. I am setting up an auth guard to control access to the routes. Whenever I use the Auth.signIn() function, the promise resolves successfully, however, when calling Auth.currentAuthenticatedUser() after signing in, the promise within the canActivate() function returns an error message "not authenticated". I have read GitHub issues on cookieStorage causing issues with this, but do not have this configured.

sign-in.component.ts

signIn(username, password) {

    return new Promise(() => {
        Auth
            .signIn(username, password)
            .then(() => {
                this.router.navigate(['main/dashboard']); // navigates to main/dashboard as expected
            })
            .catch(err => {
                this.authenticationError = err.message;
            })
    });
}

auth.guard.ts

canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
    return Auth
               .currentAuthenticatedUser()
               .then(() => { 
                   return true; 
               })
               .catch((err) => { 
                   this.router.navigate(['signin']);
                   console.log(err) // "not authenticated"
                   return false;
               });
}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Users created via the AWS management console are not considered authenticated unless the status field for that user is CONFIRMED. The status field in my case was FORCE_CHANGE_PASSWORD. AWS expects that users created via the console change their password after the first sign in or verify their account using an email or mobile verification. In the case of my app, I did not want to use either email or mobile verification. To resolve this I used the following aws-cli command for that user.

aws cognito-idp admin-set-user-password --user-pool-id your_user_pool_id --username username --password password --permanent
over 4 years ago · Santiago Trujillo Report

0

I was facing this issue also after signing up, but it turns out you also need to log the user in too after you verify email with the code.

For example:

  1. Auth.signUp
  2. Auth.confirmSignUp
  3. Auth.signIn

For more info https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!